from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain_community.llms import Tongyi
import os

os.environ["DASHSCOPE_API_KEY"]= "sk-9d8f1914800e497f8717144e860f99bc"
llm = Tongyi()
# 加载工具包
tools = load_tools(["serpapi", "llm-math"], llm=llm)
# 使用这些工具、语言模型和我们想要使用的代理类型来初始化一个代理
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
agent.invoke("Who is Leo DiCaprio's girlfriend? What is her current age raised to the 0.43 power?")